
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].[gspSiteContent_SEARCH]
(
@siteContentId int = null,
@parentSiteContentId int = null,
@title nvarchar(150) = null,
@content nvarchar(MAX) = null,
@contentTypeCode int = null,
@isDeleted bit = null,
@isVisible bit = null,
@createDate datetime = null,
@lastModifiedDate datetime = null
)
AS

SELECT
  *
FROM
  [dbo].[SiteContent]
WHERE
  (@siteContentId IS NULL OR [SiteContentId] = @siteContentId)
AND
  (@parentSiteContentId IS NULL OR [ParentSiteContentId] = @parentSiteContentId)
AND
  (@title IS NULL OR @title = '' OR [Title] LIKE @title + '%')
AND
  (@contentTypeCode IS NULL OR [ContentTypeCode] = @contentTypeCode)
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)
AND
  (@isVisible IS NULL OR [IsVisible] = @isVisible)
AND
  (@createDate IS NULL OR [CreateDate] = @createDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)

GO
